package com.yf.idmt.handler;

import com.yf.idmt.exception.MyIdempotentException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tanghailan
 * @date 2020/12/30 10:19
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

  @ExceptionHandler(value = MyIdempotentException.class)
  public Map<String, Object> MyIdempotentExceptionHandler(MyIdempotentException e) {

    Map<String, Object> map = new HashMap<>();

    map.put("data", null);
    map.put("msg", e.getMsg());
    map.put("code", e.getCode());

    return map;
  }
}
